﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using GameLayer;
using Microsoft.Xna.Framework;

namespace GameBase
{
    public class Form<T> : VisibleGameEntity<T> where T : Button
    {
        private Sprite _background;
        public Sprite Background
        {
            get { return _background; }
            set { _background = value; }
        }

        public override bool ListenEvent
        {
            get
            {
                return base.ListenEvent;
            }
            set
            {
                base.ListenEvent = value;
                foreach (var button in this.Items)
                {
                    button.ListenEvent = value;
                }
            }
        }

        protected override void UpdateEntitys(Microsoft.Xna.Framework.GameTime gameTime, object extraData)
        {
            base.UpdateEntitys(gameTime, extraData);
            foreach (var item in this.Items)
            {
                item.Update(gameTime, extraData);
            }
        }
        
        protected override void Paint(Microsoft.Xna.Framework.GameTime gameTime, Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, object extraData)
        {
            var rect = new Rectangle((int)this.Position.X, (int)this.Position.Y, (int)Size.X, (int)Size.Y);
            if (Background != null)
                Background.Draw(gameTime, spriteBatch, rect, Color.White);
            foreach (var menuItem in this.Items)
            {
                menuItem.Draw(gameTime, spriteBatch, extraData);
            }
        }
    }
}
